#include <iostream>
#include "TraitInfo.h"
#include "Reflector.h"
#include <string>
#include <memory>

using namespace OpenRA::Game::Trait;
using namespace OpenRA::Game::Tools;

class AInfo : public TraitInfo
{
public:
	int a = 10;
	void Create() override
	{
		printf("AInfo: %d\n", a);
	}
};
REFLECT_REGISTER(AInfo);

class BInfo : public TraitInfo
{
public:
	const char* b = "This is BInfo.";
	void Create() override
	{
		printf("%s\n", b);
	}
};
REFLECT_REGISTER(BInfo);

int main()
{
	std::string s;
	std::cout << "请输入类名: ";
	std::cin >> s;
	std::unique_ptr<TraitInfo> obj(Reflector::Instance()->Create(s));
	if(nullptr == obj)
	{
		std::cout << s << "不是TraitInfo的一个子类." << std::endl;
		return 1;
	}
	obj -> Create();
	return 0;
}